package org.javaboy.auth_res;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {

    /**
     * 客户端从授权服务器获取到 access_token 之后，拿着令牌就可以来访问这个接口，获取到详细的用户信息了
     * @return
     */
    @GetMapping("/user/info")
    @PreAuthorize("hasAuthority('SCOPE_message:read')")
    public Map<String, Object> userInfo() {
        Map<String, Object> userInfo = new HashMap<>();
        userInfo.put("name", "javaboy");
        userInfo.put("address", "深圳");
        return userInfo;
    }

    @GetMapping("/hello2")
    public String hello() {
        return "hello javaboy";
    }
}
